package cn.edu.zufe.mjt.bio;

import cn.edu.zufe.mjt.constans.InternetAddressConstants;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author 蒙锦涛
 * @date 2025/6/26
 */


public class BioServer {

	public static void main(String[] args) throws IOException {
		ServerSocket serverSocket = new ServerSocket(InternetAddressConstants.PORT);
		while (true) {
			Socket accept = serverSocket.accept();
			InputStream inputStream = accept.getInputStream();
			byte[] buffer = new byte[1024];
			int len;
			while ((len = inputStream.read(buffer)) != -1) {
				String message = new String(buffer, 0, len);
				System.out.println("message = " + message);
			}
			System.out.println("客户端已断开连接");
		}

	}
}
